<!doctype html>
<html class="no-js">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>注册</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" href="/static/aui/css/css/amazeui.min.css">
    <link rel="stylesheet" href="/static/aui/css/css/app.css">
    <style>
        .myapp-login .myapp-login-form .am-form .am-form-group input {
            font-size: 14px;
            padding: 10px 0;
            background: none;
            border: none;
            text-align: left;
            border-bottom: 1px solid black;
            color: black;
        }

        .myapp-login .myapp-login-form .am-form button {
            background: #367FFF;
            width: 100%;
            border-radius: 30px;
            color: #fff;
            border: none;
            font-size: 14px;
            margin-top: 20px;
        }

        input:focus {
            font-size: 14px !important;
            padding: 10px 0 !important;
            background: none !important;
            border: none !important;
            text-align: left !important;
            border-bottom: 1px solid black !important;
            color: black !important;
        }

        .tipWindow {
            display: none;
            width: 100%;
            height: 100%;
            position: fixed;
            left: 0;
            top: 0;
            right: 0;
        }

        .tipMain {
            width: 14rem;
            height: 8rem;
            background: rgba(0, 0, 0, .81);
            border-radius: .5rem;
            position: absolute;;
            left: 50%;
            margin-left: -7rem;
            top: 50%;
            margin-top: -4rem;
        }

        .tiptitle {
            padding: 1.5rem .5rem;
            overflow: hidden;
            min-height: 2rem;
            font-size: .8rem;
            line-height: 1rem;
            border-bottom: 1px solid #fff;
            text-align: center;
            color: #fff;
        }

        .erro .tipMain {
            height: 6rem;
        }

        .erro .tipMain .tiptitle {
            padding: 1rem .5rem;
            overflow: hidden;
            min-height: 1rem;
            font-size: .8rem;
            line-height: 1rem;
            border-bottom: 1px solid #fff;
            text-align: center;
            color: #fff;
        }

        .knowbtn {
            display: block;
            text-align: center;
            font-size: .875rem;
            color: #fff;
            line-height: 3rem;
        }

        .knowbtntitles {
            display: block;
            text-align: center;
            font-size: .875rem;
            color: #666;
            line-height: 3rem;
            font-size: 15px;
            float: left;
        }

        .knowbtntitle-r {
            display: block;
            text-align: center;
            font-size: .875rem;
            color: #666;
            line-height: 3rem;
            font-size: 15px;
            float: right;
        }

        .login-text {
            width: 100%;
            height: 100%;
            text-align: center;
            align-content: center;
            color: #666;
        }
    </style>
</head>
<body style="background-color: #fff">
<div class="am-g myapp-login">
    <div class="myapp-login-bg">
        <div class="myapp-login-logo">
            <img style="width:95px;height: 95px; " src="/static/aui/css/css/logos.jpg">
        </div>
        <div class="am-u-sm-10 myapp-login-form" style="margin-top: 0px;">
            <div class="am-form">

                <fieldset>
                    <input type="hidden" id="referrer_phone" name="referrer_phone" value="{$referrer_phone}">
                    <input type="hidden" id="type" name="type" value="{$type}">
                    <div class="am-form-group">
                        <label for="doc-ipt-email-1">手机号</label>
                        <input type="text" class="" hidefocus="true" id="phone" value="" placeholder="请输入手机号"
                               style=":force">
                    </div>
                    <div class="am-form-group">
                        <label for="doc-ipt-email-1">密码</label>
                        <input type="password" class="" hidefocus="true" id="pasw_login" value="" placeholder="请输入密码"
                               style=":force">
                    </div>
                    <div class="am-form-group">
                        <label for="doc-ipt-email-1">确认密码</label>
                        <input type="password" class="" hidefocus="true" id="paswto_login" value="" placeholder="请确认密码"
                               style=":force">
                    </div>
                    <div class="am-form-group">
                        <label for="doc-ipt-email-1">验证码</label>
                        <input type="text" class="" hidefocus="true" id="varifycode" value="" placeholder="请输入验证码">
                        <button type="button" class="am-btn am-btn-primary yzm "
                                style="width: 100px;position: relative;margin-top: -70px;margin-left: 60%"
                                onclick="sends.send();"><span class="send1">获取验证码</span></button>
                    </div>
                    <div class="am-form-group">
                        <label for="doc-ipt-email-1">推荐人</label>
                        <input type="text" class="" hidefocus="true" disabled
                               value="{$referrer_phone}"
                               placeholder="暂无" style=":force">
                    </div>


                    <a href="/index.php/member/Login/Make_info/referrer_phone/{$referrer_phones}/type/{$type}"
                       class="knowbtntitles"> 分享二维码？</a>
                    <a href="/index.php/member/Login/login/referrer_phone/{$referrer_phones}/type/{$type}"
                       class="knowbtntitle-r">登陆下载APP</a>
                    <p>
                        <button type="submit" id="submit" class="am-btn am-btn-default">注 册</button>
                    </p>

                </fieldset>
            </div>
        </div>
    </div>
</div>
<div class="tipWindow success">
    <div class="tipMain">
        <div class="tiptitle">注册成功</div>
        <a href="/index.php/versions/download/index" class="knowbtn">下载APP</a>
    </div>
</div>
<div class="tipWindow resphone">
    <div class="tipMain">
        <div class="tiptitle">填写正确的手机号码!</div>
        <div class="knowbtn" id="knowbtnhone">我知道了</div>
    </div>
</div>
<div class="tipWindow outpwd">
    <div class="tipMain">
        <div class="tiptitle">密码必填!</div>
        <div class="knowbtn" id="knowbtpwd">我知道了</div>
    </div>
</div>
<div class="tipWindow outpwds">
    <div class="tipMain">
        <div class="tiptitle">确认密码必填!</div>
        <div class="knowbtn" id="knowbtpwds">我知道了</div>
    </div>
</div>
<div class="tipWindow outpwdsk">
    <div class="tipMain">
        <div class="tiptitle">两次密码不一样!</div>
        <div class="knowbtn" id="knowbtpwdsk">我知道了</div>
    </div>
</div>
<div class="tipWindow outsrcf">
    <div class="tipMain">
        <div class="tiptitle">验证码必填!</div>
        <div class="knowbtn" id="knowbtsrcf">我知道了</div>
    </div>
</div>
<div class="tipWindow err">
    <div class="tipMain">
        <div class="tiptitle" id="tiptitleerr"></div>
        <div class="knowbtn" id="knowbterr">我知道了</div>
    </div>
</div>
<!--[if (gte IE 9)|!(IE)]><!-->
<script src="/static/aui/css/js/jquery.min.js"></script>
<!--<![endif]-->
<!--[if lte IE 8 ]>
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="/static/aui/assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->
<script src="/static/aui/css/js/amazeui.min.js"></script>
<script src="/static/aui/css/js/app.js"></script>
</body>
<script>

    $('#submit').click(function () {
        var referrer_phone = $('#referrer_phone').val().replace(/\s+/g, ""); //获取输入手机号码
        var phone = $('#phone').val().replace(/\s+/g, ""); //获取输入手机号码
        var type = $('#type').val().replace(/\s+/g, ""); //获取puid
        var pasw_login = $('#pasw_login').val().replace(/\s+/g, ""); //获取puid
        var paswto_login = $('#paswto_login').val().replace(/\s+/g, ""); //获取puid
        var csrf = $('#varifycode').val().replace(/\s+/g, ""); //获取验证码
        var type = $('#type').val(); //获取验证码
        var ycphone = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
        if (!phone) {
            $(".resphone").fadeIn();
            return false;
        }
        if (!type) {
            type = '';
        }


        if (!pasw_login) {
            $(".outpwd").fadeIn();
            return false;
        }
        if (!paswto_login) {
            $(".outpwds").fadeIn();
            return false;
        }
        if (pasw_login !== paswto_login) {
            $(".outpwdsk").fadeIn();
            return false;
        }
        if (!csrf) {
            $(".outsrcf").fadeIn();
            return false;
        }
        if (phone && csrf) {
            //ajax请求注册
            $.ajax({
                type: "POST",
                url: "/index.php/member/Login/save",
                data: {
                    phone: phone,
                    referrer_phone: referrer_phone,
                    password: pasw_login,
                    re_password: paswto_login,
                    validate_code: csrf,
                    type: type
                },
                dataType: "json",
                success: function (data) {
                    if (data.code == 1) {
//                        $(".success").fadeIn();
                        window.location.href = '/index.php/versions/download/index?code=' + data.data;
                        return false;
                    } else {
                        $("#tiptitleerr").html(data.msg);
                        $(".err").fadeIn();
                        return false;
                    }
                }
            });
        }
    });


    $("#knowbtpwd").click(function () {
        $(".outpwd").fadeOut();
    });
    $("#knowbtpwds").click(function () {
        $(".outpwds").fadeOut();
    });
    $("#knowbtnhone").click(function () {
        $(".resphone").fadeOut();
    });
    $("#knowbtpwdsk").click(function () {
        $(".outpwdsk").fadeOut();
    });
    $("#knowbtsrcf").click(function () {
        $(".outsrcf").fadeOut();
    });
    $("#knowbterr").click(function () {
        $(".err").fadeOut();
    });

    var sends = {
        checked: 1,
        send: function () {
            if (sends.checked == 1) {
                var numbers = /^1\d{10}$/;
                var val = $('#phone').val().replace(/\s+/g, ""); //获取输入手机号码
                if ($('.yzm span').attr('class') == 'send1') {
                    if (!numbers.test(val) || val.length == 0) {
                        //$('.div-phone').append('<span class="error">手机格式错误</span>');
                        $(".resphone").fadeIn();
                        return false;
                    }
                }
                if (numbers.test(val)) {
                    var time = 30;
                    var timer;

                    function timeCountDown() {
                        if (time == 0) {
                            clearInterval(timer);
                            $('.yzm span').addClass('send1').removeClass('send0').html("发送验证码");
                            sends.checked = 1;
                            return true;
                        }
                        $('.yzm span').html(time + "S后发送");
                        sends.checked = 0;
                        time--;
                        return false;
                    }

                    //ajax请求验证码
                    $.ajax({
                        type: "POST",
                        url: "/index.php/member/Login/push_phone_code",
                        data: {phone: val},
                        dataType: "json",
                        success: function (data) {
                            if (data.code == 1) {
                                $('.yzm span').addClass('send0').removeClass('send1');
                                timeCountDown();
                                timer = setInterval(timeCountDown, 1000);
                            } else {
                                alert(data.msg);
                            }
                        }
                    });


                }
            }
        }
    }
</script>
</html>